﻿@model WebVideo.Areas.Admin.Models.Questions_MultipleChoiceModel    
@{
    ViewBag.Title = "Edit";
    Layout = "~/Areas/Admin/Views/Shared/_Layout.cshtml";
}

<script src="@Url.Content("~/Content/cssAdmin/js/plugins/jquery-1.7.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Content/cssAdmin/js/plugins/jquery-ui-1.8.16.custom.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Content/cssAdmin/js/plugins/jquery.validate.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Content/cssAdmin/js/plugins/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Content/cssAdmin/ckeditor/ckeditor.js")" type="text/javascript"></script>
@*<script>
    var ckeditor;
    function create(languageCode, id) {
        var editor = CKEDITOR.replace(id, { language: languageCode });
    }
    $(function () { create("vi", "Des") });
</script>*@

<script type="text/javascript">
    jQuery(document).ready(function () {

        $('#nofSuccess').hide(); // an thong bao
        $('#nofError').hide();
        $('#errorlist').hide();
        readyValue();
    });
    function alertMsg(msg) {
        $('#nofSuccess').hide();
        $('#nofError').show();
        $('#msgNofError').text(msg);
    }
    function checkField() {
        var image = $("#Image").val();


        if (image == null || image == "") {
          // do nothing
        }
        else {
            var ext = image.substring((Math.max(0, image.lastIndexOf(".")) || image.length) + 1);
            ext = ext.toLowerCase();

            if (ext != "jpg" && ext != "jpeg" && ext != "gif" && ext != "png") {

                msg = "! Upload file hình có định dạng jpg, jpeg, gif hoặc png";
                alertMsg(msg);
                return false;
            }
        }
        return true;

    }

</script>

<div class="maincontentinner">
    <ul class="maintabmenu">
      <li class="current"><a href="@Url.Action("Index", "Questions_MultipleChoice",new { Id = ViewBag.IdVideo })")" >Index</a></li>
    </ul>
    <!--maintabmenu-->
    <div class="notification msgsuccess" style="display: none" id="nofSuccess">
        <a class="close"></a>
        <p id="msgNofSuccess">This is a success message.</p>
    </div>
    <!-- notification msgsuccess -->
    <div class="notification msgerror" style="display: none" id="nofError">
        <a class="close"></a>
        <p id="msgNofError">This is an error message.</p>
    </div>
    <!-- notification msgerror -->
    <div class="contenttitle radiusbottom0">
        <h2 class="table"><span>Edit  MultipleChoice Questions</span></h2>
    </div>
    <!--contenttitle-->
    @using (Html.BeginForm("Edit", "Questions_MultipleChoice",
            new { ReturnUrl = ViewBag.ReturnUrl },
            FormMethod.Post, new { @class = "stdform stdform2", @enctype = "multipart/form-data" }))
    {
         <p>
                <span class="field">
                    @Html.HiddenFor(model => model.Id)
                </span>
            </p>
        if(Model.Type == 1)
        {
           
             <p>
                <label>Hình hiện tại</label>
                <span class="field">
                    @{
                        var imageFile = "~/Content/Images/Video/";
                        if (@Model.Image != null)
                        {
                            imageFile += @Model.Image;
                        }
                        else
                        {
                            imageFile += "no-photo.jpg";
                        }
                    }
                    <img src="@Url.Content(@imageFile)" alt="" style="height:100px; width:100px" />
                </span>
            </p>
             <p>
                <label>hình ảnh</label>
                <span class="field">
                    @Html.TextBoxFor(model => model.Image, new { type = "file" })
                </span>
            </p>
        }
       
        @*<p>
            <label>Tên câu hỏi</label>
            <span class="field">
                @Html.EditorFor(model => model.Name)
                @Html.ValidationMessageFor(model => model.Name)
            </span>
        </p>*@
        <p>
            <label>Nội dung </label>
            <span class="field">
                 @Html.TextAreaFor(model => model.Des)
                <br />
                @Html.ValidationMessageFor(model => model.Des)
            </span>
        </p>
        <p>
             <label>Danh sách câu hỏi <small >Bạn vui lòng check câu đúng</small> </label>
            <span class="field">
                 @Html.ValidationMessageFor(model => model.Result)<br />
               Câu a: @Html.EditorFor(model => model.QuesA)&nbsp;&nbsp;<input name="Result" type="radio" value="a"/>  @Html.ValidationMessageFor(model => model.QuesA)
                <br />
                <br />

               Câu b: @Html.EditorFor(model => model.QuesB)&nbsp;&nbsp;<input name="Result" type="radio" value="b"/>@Html.ValidationMessageFor(model => model.QuesB)
                <br />
                <br />
               Câu c: @Html.EditorFor(model => model.QuesC)&nbsp;&nbsp;<input name="Result" type="radio" value="c"/>@Html.ValidationMessageFor(model => model.QuesC)
                <br />
                <br />
               Câu d: @Html.EditorFor(model => model.QuesD)&nbsp;&nbsp;<input name="Result" type="radio" value="d"/>@Html.ValidationMessageFor(model => model.QuesD)
                <br />
               
            </span>
        </p>
         <p>
            <span class="field">
                @Html.HiddenFor(model => model.IdVideo)
            </span>
        </p>
        
        <p class="stdformbutton">
            <input type="submit" value="Chấp nhận"  onclick="return checkField()"/>
            <input type="submit" value="Quay lại" onclick="javascript: history.back(); return false" />
        </p>  
    }
    <br clear="all" />
</div>
<!--maincontentinner-->

